<template>
  <div>
    <el-form
      ref="editFormRef"
      :model="editForm.data"
      label-width="120"
      @change="editData"
    >
      <el-row>
        <el-col :span="10">
          <el-form-item label="外来车辆停放" prop="tempEntry">
            <el-radio-group v-model="editForm.data.tempEntry">
              <el-radio
                v-for="item in tempEntryList.data"
                :key="item.id"
                :value="item.id"
              >
                {{ item.name }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="免费离场时间" prop="leaveTime">
            <el-input
              v-model="editForm.data.leaveTime"
              style="width: 320px"
              placeholder="请输入免费离场时间"
            >
              <template #append>分钟</template>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="线上卡办理" prop="cardOnline">
            <el-radio-group v-model="editForm.data.cardOnline">
              <el-radio
                v-for="item in cardOnlineList.data"
                :key="item.id"
                :value="item.id"
              >
                {{ item.name }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="电子停车券" prop="elecCoupon">
            <el-radio-group v-model="editForm.data.elecCoupon">
              <el-radio
                v-for="item in elecCouponList.data"
                :key="item.id"
                :value="item.id"
              >
                {{ item.name }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="车场预约" prop="reservable">
            <el-radio-group v-model="editForm.data.reservable">
              <el-radio v-for="item in reserveList.data" :key="item.id" :value="item.id">
                {{ item.name }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="电子发票" prop="elecInvoice">
            <el-radio-group v-model="editForm.data.elecInvoice">
              <el-radio
                v-for="item in elecInvoiceList.data"
                :key="item.id"
                :value="item.id"
              >
                {{ item.name }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";

const emits = defineEmits(["edit"]);

const props = defineProps({
  editOrderDetails: {
    type: Object,
    default: () => {},
  },
});
console.log(props.editOrderDetails);

const editFormRef = ref("");
const editForm = reactive({
  data: {
    tempEntry: props.editOrderDetails.tempEntry == true ? 1 : 0,
    leaveTime: props.editOrderDetails.leaveTime,
    cardOnline: props.editOrderDetails.cardOnline == true ? 1 : 0,
    elecCoupon: props.editOrderDetails.elecCoupon == true ? 1 : 0,
    reservable: props.editOrderDetails.reservable == true ? 1 : 0,
    elecInvoice: props.editOrderDetails.elecInvoice == true ? 1 : 0,
  },
});

const tempEntryList = reactive({
  data: [
    {
      id: 1,
      name: "启用",
    },
    {
      id: 0,
      name: "关闭",
    },
  ],
});

const cardOnlineList = reactive({
  data: [
    {
      id: 1,
      name: "启用",
    },
    {
      id: 0,
      name: "关闭",
    },
  ],
});

const elecCouponList = reactive({
  data: [
    {
      id: 1,
      name: "启用",
    },
    {
      id: 0,
      name: "关闭",
    },
  ],
});

const reserveList = reactive({
  data: [
    {
      id: 1,
      name: "启用",
    },
    {
      id: 0,
      name: "关闭",
    },
  ],
});

const elecInvoiceList = reactive({
  data: [
    {
      id: 1,
      name: "启用",
    },
    {
      id: 0,
      name: "关闭",
    },
  ],
});

const editData = () => {
  // console.log(editForm.data);
  emits("edit", editForm.data);
};
</script>
